﻿//统一文件为utf-8编码编译
#pragma execution_character_set("utf-8")
///////////////////////////////////////////////////////////////////////////
// 文件名:     delegatecenter.h
// 描述:
// 作者:      颜磊
// 创建时间:   2024-06-09 00:55
///////////////////////////////////////////////////////////////////////////
#ifndef DELEGATECENTER_H
#define DELEGATECENTER_H
#include <QItemDelegate>

class EnumDelegate : public QItemDelegate
{
    Q_OBJECT
public:
   EnumDelegate(QStringList enumStringList, QObject *parent=nullptr);
   
private:
   QStringList enumStringList;
   
public:
   void initStyleOption(QStyleOptionViewItem *option,const QModelIndex &index) const;
   QString getDisplayText(const QModelIndex &index) const;
   
protected:
   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};

class NumberDelegate : public QItemDelegate
{
    Q_OBJECT
public:
   NumberDelegate(int precision, QObject *parent=nullptr);

private:
   int precision;

public:
   void initStyleOption(QStyleOptionViewItem *option,const QModelIndex &index) const;
   QString getDisplayText(const QModelIndex &index) const;

protected:
   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};

class ProgressDelegate : public QItemDelegate
{
    Q_OBJECT
public:
   ProgressDelegate(QObject *parent=nullptr);

public:
   void initStyleOption(QStyleOptionViewItem *option,const QModelIndex &index) const;
   QString getDisplayText(const QModelIndex &index) const;

protected:
   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};


class ByteDelegate : public QItemDelegate
{
    Q_OBJECT
public:
   ByteDelegate(QObject *parent=nullptr);

public:
   void initStyleOption(QStyleOptionViewItem *option,const QModelIndex &index) const;
   QString getDisplayText(const QModelIndex &index) const;

protected:
   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};


/**
 * @brief The DivisionDelegate class 数字分割代理
 */
class DivisionDelegate : public QItemDelegate
{
    Q_OBJECT
public:
   DivisionDelegate(int interval,int precision = 0,QObject *parent=nullptr);

private:
   int interval;
   int precision;
public:
   void initStyleOption(QStyleOptionViewItem *option,const QModelIndex &index) const;
   QString getDisplayText(const QModelIndex &index) const;

protected:
   void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
#endif // DELEGATECENTER_H
